home *** CD-ROM | disk | FTP | other *** search
/ Programming a Multiplayer FPS in DirectX / Programming a Multiplayer FPS in DirectX (Companion CD).iso / DirectX / dxsdk_oct2004.exe / dxsdk.exe / Documentation / DirectX9 / directx9_c.chm / directx / code / appliesto2.js next >
Encoding:
JavaScript  |  2004-09-30  |  13.9 KB  |  387 lines

  1. /* InetSDK Applies To Code */
  2.  
  3. /* Note -- hard coded links are added to the style comments in fnPostAtInit */
  4.  
  5. // General comments are stored in this string.
  6. var sGeneralComments="";
  7.  
  8. // Style comments are stored in this string.
  9. var sStyleComments="";
  10.  
  11. // Default help text.
  12. var sHelpText="Move the mouse pointer over an element in the Applies To list to display availability information for the listed platforms.";
  13.  
  14. /*
  15.     Platform information displayed within the info-block of the table.
  16.     This hash works in conjunction with the platform names provided in the PLATINFO attribute of a link.
  17. */
  18. var _gvRowData=new Array();
  19. _gvRowData["win16"]={"name":"16-bit Windows","displayName":"Win16","row":0};
  20. _gvRowData["win32"]={"name":"32-bit Windows","displayName":"Win32","row":0};
  21. _gvRowData["ce"]={"name":"Windows CE","displayName":"WinCE","row":0};
  22. _gvRowData["unix"]={"name":"Unix","displayName":"Unix","row":0};
  23. _gvRowData["mac"]={"name":"Macintosh","displayName":"Mac","row":0};
  24. _gvRowData["plat:win"]={"name":"Windows","displayName":"Win","row":0};
  25.  
  26. var bATInit=false;
  27.  
  28. /*
  29.     void fnATInit();
  30.     Invoked by PostGBInit in common.js
  31.     Initializes the applies to list and sets the global init boolean to true.
  32. */
  33. function fnATInit(){
  34.     if(typeof(oATTable) != 'undefined' && bATInit==false){
  35.         fnPostATInit();
  36.         bATInit=true;
  37.     }
  38. }
  39.  
  40. /*
  41.     void fnPostATInit();
  42.     Invoked by fnATInit.
  43.     Sets up the UI, adds event handlers to links.
  44. */
  45. function fnPostATInit(){
  46.     // Setup table when browser version is greater or equal to 4.
  47.     var oATNodes=oATData.all.tags("A");
  48.     if(oATNodes.length==0) oATNodes = oATData.all.tags("link");
  49.     var iMinVer=-1;
  50.     var vUseRowData={};
  51.     var vUseRowNames=new Array();
  52.     
  53.     var iStyleVer=0;
  54.     var iCurrentStyleVer=0;
  55.     var iRuntimeStyleVer=0;
  56.     var iMinStyleVer=0;
  57.     var oExp=new RegExp("\\s","g");    
  58.  
  59.     /*
  60.         Loop through the links, set focus and blur event handlers,
  61.         find the minimum versions, 
  62.         determine which platform rows to display.
  63.     */
  64.     for(var i=0;i<oATNodes.length;i++){
  65.         var oNode=oATNodes[i];
  66.         if(oNode.tagName=="A" || oNode.tagName=="link"){
  67.             oNode.onfocus=fnATData;
  68.             oNode.onblur=fnATClear;            
  69.             var sPlatInfo=oNode.getAttribute("PLATINFO");
  70.             var sLinkName=oNode.innerText;
  71.             if(sPlatInfo!=null){
  72.                 var aTemp=sPlatInfo.split(";");
  73.                 for(var p=0;p<aTemp.length;p++){
  74.                     var aThrash=aTemp[p].split("=");
  75.                     var sVer=aThrash[1].replace(oExp,"");
  76.                     var sPlatName=aThrash[0];
  77.                     if((!vUseRowData[sPlatName])){
  78.                         vUseRowData[sPlatName]=1;
  79.                         vUseRowNames[vUseRowNames.length]=sPlatName;
  80.                     }
  81.                     var iVer=parseFloat(aThrash[1]);
  82.                     if(iVer>0 && iMinVer<0){
  83.                         iMinVer=iVer;
  84.                     }
  85.                     if(iVer>0 && iVer<iMinVer){
  86.                         iMinVer=iVer;
  87.                     }
  88.                     if(iVer>0){
  89.                         switch(sLinkName){
  90.                             case "style":
  91.                                 iStyleVer=(iVer<iStyleVer || iStyleVer==0)?iVer:iStyleVer;
  92.                                 iMinStyleVer=(iVer<iMinStyleVer || iMinStyleVer==0)?iVer:iMinStyleVer;
  93.                                 break;
  94.                             case "runtimeStyle":
  95.                                 iRuntimeStyleVer=(iVer<iRuntimeStyleVer || iRuntimeStyleVer==0)?iVer:iRuntimeStyleVer;
  96.                                 iMinStyleVer=(iVer<iMinStyleVer || iMinStyleVer==0)?iVer:iMinStyleVer;                            
  97.                                 break;
  98.                             case "currentStyle":
  99.                                 iCurrentStyleVer=(iVer<iCurrentStyleVer || iCurrentStyleVer==0)?iVer:iCurrentStyleVer;
  100.                                 iMinStyleVer=(iVer<iMinStyleVer || iMinStyleVer==0)?iVer:iMinStyleVer;                            
  101.                                 break;
  102.                         }
  103.                     }
  104.                     
  105.                 }
  106.             }
  107.         }
  108.     }
  109.     // Get project name from _topicdata XML data island, set project specific help strings.
  110.     if(typeof(_topicdata)=="object" && _topicdata.tagName=="XML"){
  111.         var sMemberName=_topicdata.getAttribute("name");
  112.         var sPN=_topicdata.getAttribute("pn");
  113.         var sMemberType=(sPN==null)?"property":"attribute";
  114.         sMemberName=(sPN==null)?sMemberName:sPN;
  115.         
  116.         var sProj=_topicdata.getAttribute("proj");
  117.         var sAddHelpString="";
  118.         // Add project specific help messages here.
  119.         if(sProj){
  120.             switch(sProj){
  121.                 case "pchealth":
  122.                     break;
  123.                 case "workshop":
  124.                     sAddHelpString="  Internet Explorer does not expose this member on platforms that are not listed.";
  125.                     break;
  126.             }
  127.         }
  128.         sHelpText+=sAddHelpString;
  129.  
  130.         // Check _topicdata to determine if the reference is a style and/or currentstyle member
  131.         var bIsCurrentStyleProp=(_topicdata.getAttribute("is_currentstyle_prop"))?true:false;
  132.         var bIsStyleProp=(_topicdata.getAttribute("is_style_prop"))?true:false;
  133.         
  134.         // If the member name or persistent name exists on _topicdata, and the document is a style or current style property, then formulate the dynamic sentence.
  135.         if(sMemberName!=null && (bIsStyleProp ||  bIsCurrentStyleProp)){
  136.             var vUseVer=iMinStyleVer;
  137.  
  138.             var vStyleLink='<A STYLE="color: #2277FF;" HREF="/workshop/author/dhtml/reference/objects/obj_style.asp">style</A>';
  139.             var vCurrentStyleLink='<A STYLE="color: #2277FF;" HREF="/workshop/author/dhtml/reference/objects/currentStyle.asp">currentStyle</A>';
  140.             var vRuntimeStyleLink='<A STYLE="color: #2277FF;" HREF="/workshop/author/dhtml/reference/objects/runtimeStyle.asp">runtimeStyle</A>';
  141.             
  142.             // The style property was first available in IE 4.  This condition is present for error-checking.
  143.             if(iMinStyleVer<4 && iMinStyleVer>0){
  144.                 vUseVer="4.0";
  145.             }
  146.             
  147.             // Use iMark to determine the grammar of the prepositional phrase (object., or object, object, object, or object).
  148.             var iMark=0;
  149.  
  150.             // If the member is a style property, the style property is greater than 0 (default), and the style property version is equal to the minimum *style version, then add the link and increment iMark.
  151.  
  152.             var aStyleObjList = new Array();
  153.  
  154.             if(bIsStyleProp && iStyleVer>0 && iStyleVer==iMinStyleVer){
  155.                 aStyleObjList[aStyleObjList.length] = vStyleLink;
  156.             }
  157.             if(iCurrentStyleVer>0 && iCurrentStyleVer==iMinStyleVer){
  158.                 aStyleObjList[aStyleObjList.length] = vCurrentStyleLink;
  159.             }
  160.             if(iRuntimeStyleVer>0 && iRuntimeStyleVer==iMinStyleVer){
  161.                 aStyleObjList[aStyleObjList.length] = vRuntimeStyleLink;
  162.             }
  163.  
  164.             if (aStyleObjList.length > 0)
  165.             {
  166.                 sStyleComments="Objects that expose the <B>" + sMemberName + "</B> " + sMemberType + " as of Internet Explorer " + vUseVer + " or later are accessible through script using the ";
  167.  
  168.                 switch(aStyleObjList.length)
  169.                 {
  170.                     case 1:
  171.                         sStyleComments += aStyleObjList[0];
  172.                         break;
  173.                     case 2:
  174.                         sStyleComments += aStyleObjList[0] + " or " + aStyleObjList[1];
  175.                         break;
  176.                     default:
  177.                         for (var i = 0; i < aStyleObjList.length; i++)
  178.                         {
  179.                             sStyleComments += aStyleObjList[i];
  180.                             if (i == aStyleObjList.length-2)
  181.                             {
  182.                                 sStyleComments += ", or ";
  183.                             }
  184.                             else                            
  185.                             {
  186.                                 sStyleComments += ", ";
  187.                             }
  188.                         }
  189.                         sStyleComments = sStyleComments.replace(/,\s*$/, "");
  190.                 }    
  191.                 sStyleComments += " object" + (aStyleObjList.length > 1 ? "s" : "") + ".";
  192.             }
  193.             
  194.             // This condition checks if the member was exposed to the style object before or at the same time as the currentStyle and runtimeStyle objects.
  195.             if(iCurrentStyleVer > iMinStyleVer || iRuntimeStyleVer>iMinStyleVer){
  196.                 var iNextMin=(iRuntimeStyleVer>iMinStyleVer && iRuntimeStyleVer<=((iCurrentStyleVer>iMinStyleVer)?iCurrentStyleVer:iRuntimeStyleVer))?iRuntimeStyleVer:iCurrentStyleVer;
  197.                 sStyleComments+="  They are also accessible in Internet Explorer " + iNextMin + " or later using the ";
  198.                 if(iCurrentStyleVer==iRuntimeStyleVer){
  199.                     sStyleComments+=vCurrentStyleLink + " object or the " + vRuntimeStyleLink + " object.";
  200.                 }
  201.                 else{
  202.                     if(iCurrentStyleVer > iMinStyleVer && iCurrentStyleVer==iNextMin){
  203.                         sStyleComments+=vCurrentStyleLink + " object";
  204.                     }
  205.                     if(iRuntimeStyleVer>iMinStyleVer && iRuntimeStyleVer==iNextMin){
  206.                         sStyleComments+=vRuntimeStyleLink + " object";
  207.                     }
  208.                 }
  209.                 if(iCurrentStyleVer > iNextMin || iRuntimeStyleVer>iNextMin){
  210.                     var iMax=(iCurrentStyleVer>iRuntimeStyleVer)?iCurrentStyleVer:iRuntimeStyleVer;
  211.                     var vLink=(iCurrentStyleVer>iRuntimeStyleVer)?vCurrentStyleLink:vRuntimeStyleLink;
  212.                     sStyleComments+=", and in Internet Explorer " + iMax + " or later using the " + vLink + " object.";
  213.  
  214.                 }
  215.                 else{
  216.                     sStyleComments+=".";
  217.                 }
  218.             }
  219.         }
  220.     }
  221.     
  222.     // Create the platform columns.
  223.     fnAddATDataRows(vUseRowNames);
  224.     // Set display styles and event handlers.
  225.     if(vUseRowNames.length>0){
  226.         oATData.width="85%";
  227.         oPlatData.width="100%";
  228.         oPlatData.parentElement.style.display="block";
  229.         oATData.onmouseover=fnATData;
  230.         oATData.onmouseout=fnATClear;
  231.         oATData.onfocus=fnATData;
  232.         oATData.onblur=fnATClear;
  233.         var oATC=oATTable.rows(oATTable.rows.length-1).cells(0);
  234.         oATC.innerHTML=sHelpText;
  235.         oATC.style.display="block";
  236.         var oHasFocus=document.activeElement;
  237.         if(oHasFocus.parentElement==oATData){
  238.             fnUnPack(oHasFocus,true);
  239.         }
  240.         else{
  241.             oATHelp.style.display="block";
  242.         }
  243.     }
  244. }
  245.  
  246. /*
  247.     void fnAddATDataRows(ARRAY aUseRowNames);
  248.     Invoked by fnPostATInit
  249.     Builds the platform and version information table.
  250. */
  251. function fnAddATDataRows(aUseRowNames){
  252.     var sTableData='<TABLE CLASS="TMATPD" ID="oPlatData" BORDER="0" CELLSPACING="1">';
  253.     sTableData+='<TR><TH STYLE="font-weight: normal;" CLASS="atLabel" TITLE="The name of the object that has focus or is selected in the applies to list." COLSPAN=2>[ Object Name ]</TH></TR>';
  254.     sTableData+='<TR><TH CLASS="atLabel" TITLE="Platforms that run Internet Explorer.">Platform</TH><TH  CLASS="atLabel" TITLE="This column lists the first version of Internet Explorer that the selected element supported this member." >Version</TH></TR>';
  255.     // iRowIndex is set to 2 because the first two rows (above) are used for labels.
  256.     var iRowIndex=2;
  257.     var iUseLen=aUseRowNames.length;
  258.     for(var i=0;i<iUseLen;i++){
  259.         var sPlatName=aUseRowNames[i];
  260.         var vData=_gvRowData[sPlatName];
  261.         // If the platform name is defined in the global hash (defined at top of this file), then add the row and record the row index for use when updating the values.
  262.         // The row is hidden until the first call fnUnPack()
  263.         if(vData){
  264.             sTableData+='<TR STYLE="cursor: default;display: none;" TITLE="Version of Internet Explorer that the selected element supported this member for the ' + vData.name + ' platform."><TD>' + vData.displayName + ':</TD><TD STYLE="text-align: right;"></TD></TR>';
  265.             _gvRowData[sPlatName].row=iRowIndex;
  266.             iRowIndex++;
  267.         }
  268.     }
  269.     // Add the help row.
  270.     sTableData+='<TR STYLE="display: none; font-size: 8pt;" ID=oATHelp><TD COLSPAN=2>Version data is listed when the mouse hovers over a link, or the link has focus.</TD></TR>';
  271.     sTableData+='</TABLE>';
  272.     if(iUseLen>0){
  273.         // Insert the HTML into the applies-to table.
  274.         oATTable.rows(0).cells(0).innerHTML=sTableData;
  275.     }
  276. }
  277.  
  278. /*
  279.     void fnATClear()
  280.     Invoked by blur and mouseout events.
  281.     Calls fnUnPack on the active element if it is an applies to list node.
  282.  
  283. */
  284. function fnATClear(){
  285.     var oHasFocus=document.activeElement;
  286.     if(oHasFocus.parentElement==oATData){
  287.         fnUnPack(oHasFocus,false);
  288.     }
  289. }
  290.  
  291. /*
  292.     void fnATData();
  293.     Invoked by mouseover and focus events.
  294.     Call fnUnPack on the source element if it is a hyperlink.
  295. */
  296. function fnATData(){
  297.     var oWorkItem=event.srcElement;
  298.     if(oWorkItem.tagName=="A" || oWorkItem.tagName=="link"){
  299.         fnUnPack(oWorkItem,false);
  300.     }
  301. }
  302.  
  303. /*
  304.     void fnUnPack(IHTMLElement oNode, BOOL bWasActiveElement)
  305.     Invoked by fnATData, fnATClear, or fnPostATInit
  306.     Displays information stored in the PLATINFO attribute in the embedded platform and version table.
  307. */
  308. function fnUnPack(oNode,bWasActiveElement){
  309.     if((typeof(oATHelp)=='object') && (typeof(oPlatData)=='object')){
  310.         if(oATHelp.style.display!="none" || bWasActiveElement){
  311.             oATHelp.style.display="none";
  312.             for(var i=0;i<oPlatData.rows.length;i++){
  313.                 var oRow=oPlatData.rows[i];
  314.                 if(oRow!=oATHelp){
  315.                     oRow.style.display="block";
  316.                 }
  317.             }
  318.         }
  319.         // all values default to N/A
  320.         // first two rows, and the last row, are for labels
  321.         var aRows=oPlatData.rows;
  322.         for(var i=2;i<aRows.length-1;i++){
  323.             aRows(i).cells(1).innerText="N/A";
  324.         }
  325.         
  326.         // Split the value of the PLATINFO attribute and display it in the appropriate row.
  327.         var sPlatInfo=oNode.getAttribute("PLATINFO");
  328.         if(sPlatInfo){
  329.             var aATThrash=sPlatInfo.split(";");
  330.             var oExp=new RegExp("\\s","g");
  331.             for(var i=0;i<aATThrash.length;i++){
  332.                 var aPlatThrash=aATThrash[i].split("=");
  333.                 var sPlatName=aPlatThrash[0];
  334.                 if((sPlatName!="")&&(aPlatThrash[1]!="")){
  335.                     var vData=_gvRowData[sPlatName];
  336.                     if(vData && vData.row){
  337.                         var oRow=oPlatData.rows[vData.row];
  338.                         var sVer=aPlatThrash[1];
  339.                         sVer=sVer.replace(oExp,"");
  340.                         if(sVer=="NA"){
  341.                             sVer="N/A";
  342.                         }
  343.                         oRow.cells(1).innerText=sVer;
  344.                     }
  345.                 }
  346.             }
  347.         }
  348.         
  349.         // Clip the label if the length is greater than 13; this is for display purposes.
  350.         var sLabelName=oNode.innerText;
  351.         if(sLabelName.length>13){
  352.             sLabelName=sLabelName.substring(0,13) + "...";
  353.         }
  354.         
  355.         // Set the label and tooltip to the anchor caption.
  356.         oPlatData.rows(0).cells(0).innerText=sLabelName;
  357.         oPlatData.rows(0).cells(0).title=oNode.innerText;    
  358.     
  359.         /*
  360.             Member comments are stored in a comment element as a sibling to the link.
  361.             If the next sibling is a comment (.nextSibling for IE 5 or later, object.sourceIndex+1 for IE 4), then display that comment in the notes section.
  362.         */
  363.         var oATComment=document.all[oNode.sourceIndex+1];
  364.         var sATComment="";
  365.         var oATC=oATTable.rows(oATTable.rows.length-1).cells(0);
  366.         if(typeof(oATComment)=="object"){
  367.             if((oATComment.tagName=="!")||(oATComment.tagName=="COMMENT")){
  368.                 sATComment=oATComment.outerHTML;
  369.                 var oExp=new RegExp("(<!--|-->)","g");
  370.                 sATComment=sATComment.replace(oExp,"");
  371.             }
  372.         }
  373.         if(sATComment!=""){
  374.             oATC.innerHTML=sATComment + "<BR>";
  375.             oATC.innerHTML+=sGeneralComments + sStyleComments;
  376.         }
  377.         else{
  378.             if((sGeneralComments=="")&&(sStyleComments=="")){
  379.                 oATC.innerHTML=sHelpText;
  380.             }
  381.             else{
  382.                 oATC.innerHTML=sGeneralComments + sStyleComments;
  383.             }
  384.         }
  385.     }
  386. }
  387.